home *** CD-ROM | disk | FTP | other *** search
/ PC World Interactive 7 / PC World Interactive 7.iso / program / pasprog.EXE / RECPLAY.PAS < prev    next >
Pascal/Delphi Source File  |  1994-10-28  |  3KB  |  80 lines

  1. program RecPlay;
  2.     uses
  3.         CRT,
  4.         SBVox;
  5.     const
  6.         RecordLength = 4;     {Seconds}
  7.         SamplingRate = 22050; {HZ}
  8.         SoundSize = RecordLength * SamplingRate;
  9.         InterruptNum = 5;      {/ YOU WILL PROBABLY HAVE}
  10.         BaseIOaddress = $220;  {\ TO CHANGE THESE CONSTS}
  11. {$IFNDEF LinkDriver}
  12.         DriverPath    = ''; {'' if the driver is in the current directory}
  13. {$ENDIF}
  14.     var
  15.         Result : word;
  16.         Sound  : PSound;
  17.         i      : word;
  18.     begin
  19.         writeln; writeln; writeln;
  20.  
  21. {$IFNDEF LinkDriver}
  22.         Result := LoadDriver(DriverPath + 'CT-VOICE.DRV');
  23. {$ELSE}
  24.         writeln('Driver linked into executable'); Result := LoadDrvSuccess;
  25. {$ENDIF}
  26.         case Result
  27.             of
  28.                 LoadDrvSuccess:   writeln('Sound Blaster driver loaded successfully');
  29.                 LoadDrvIOerror:   writeln('IO error loading Sound Blaster driver');
  30.                 LoadDrvNoMemory:  writeln('Not enough memory to load Sound Blaster driver');
  31.                 LoadDrvBadDriver: writeln('Sound Blaster driver is corrupted');
  32.             end;
  33.         if Result <> 0 then Halt(255);
  34.         writeln('CT-VOICE Driver Version: ', Hi(GetDriverVersion), '.', Lo(GetDriverVersion));
  35.         SetInterrupt(InterruptNum);      writeln('Interrupt Number set to ', InterruptNum);
  36.         SetBaseIOAddress(BaseIOaddress); writeln('Base IO address set');
  37.         Result := InitSB; write('Attempting to initialize Sound Blaster:   ');
  38.         case Result
  39.             of
  40.                 SBInitSuccess:                writeln('SB Initialized Correctly');
  41.                 SBInitSoundCardFailure:       writeln('Sound Card Failure');
  42.                 SBInitIOFailure:              writeln('IO Failure');
  43.                 SBInitDMAorInterruptFailure:  writeln('DMA or Interrupt Failure');
  44.             end;
  45.         if Result <> LoadDrvSuccess then Halt(255);
  46.         InitStatusWord;
  47.         TurnSpeakerOn;
  48.  
  49.         GetSoundBuffer(Sound, SoundSize);
  50.  
  51.         TurnSpeakerOff; {Prevents feedback}
  52.         writeln('Sound recording at ', SamplingRate, ' HZ begining');
  53.         writeln('Press and key to stop recording');
  54.         RecordSound(Sound, SoundSize, SamplingRate);
  55.         repeat
  56.             if KeyPressed
  57.                 then
  58.                     begin
  59.                         StopSound;
  60.                         writeln('Sound recording stopped by key press');
  61.                         Break;
  62.                     end;
  63.         until (StatusWord = SoundCompleted);
  64.         writeln('Sound recording ending');
  65.         writeln('Press any key to begin playback');
  66.         repeat until KeyPressed; ReadKey;
  67.         TurnSpeakerOn;
  68.         writeln('Output of sound recording begin');
  69.         PlaySound(Sound);
  70.         repeat until (StatusWord = SoundCompleted);
  71.         writeln('Output of sound recording ending');
  72.         TurnSpeakerOff;
  73.  
  74.         FreeSoundBuffer(Sound, SoundSize);
  75. {$IFDEF LinkDriver}
  76.         ShutDownDriver;
  77. {$ELSE}
  78.         UnloadDriver;
  79. {$ENDIF}
  80.     end.